package kotlindemo.com.kotlindemo

import java.lang.Exception
import java.lang.IllegalArgumentException
//sealed 被sealed修饰的都是密封类
sealed class Result
class Success(val msg: String) : Result()
class Failure(val error: Exception) : Result()

fun getResultMsg(result: Result) = when (result) {
    is Success ->result.msg
    is Success ->result.msg
    else ->throw IllegalArgumentException()
}